<h1>Class Reference</h1>

<p>
    <ul>
        <li><a href="#Acl">Acl Class</a></li>
        <li><a href="#">Encrypt Class</a></li>
        <li><a href="#">Form Validation Class</a></li>
        <li><a href="#">Session Class</a></li>
        <li><a href="#">Template Class</a></li>
        <li><a href="#">Translation Class</a></li>
    </ul>
</p>

<br />

<div id="Acl">
    <h1>Acl Class</h1>
    
    <p>G has an excellent Acl Class, which helps you defining resource access to different roles.
    Your applictation is highly maintainable when using an Acl.</p>
    
    <h2>Class Methods</h2>
    <p>
        <ul>
            <li><a href="#Acl_addRole">addRole()</a></li>
            <li><a href="#Acl_allow">allow()</a></li>
            <li><a href="#Acl_checkAcl">checkAcl()</a></li>
            <li><a href="#Acl_deny">deny()</a></li>
            <li><a href="#Acl_getDefaultRole">getDefaultRole()</a></li>
            <li><a href="#Acl_getInstance">getInstance()</a></li>
            <li><a href="#Acl_getRedirectUrl">getRedirectUrl()</a></li>
            <li><a href="#Acl_isAllowed">isAllowed()</a></li>
            <li><a href="#Acl_setDefaultRole">setDefaultRole()</a></li>
            <li><a href="#Acl_setRedirectUrl">setRedirectUrl()</a></li>
        </ul>
    </p>
    
    <br />
    
    <!-- Acl::addRole() -->
    <div id="Acl_addRole">
        <h3>+ addRole(<span>string</span> $role, <span>string</span> $inherits)<span class="return">:void</span></h3>
        <p>This method add's a Acl Role object to the roles array of the Acl object.</p>

        <table cellspacing="0">
            <tr>
                <th width="100">Parameter</th>
                <th width="60">Type</th>
                <th>Description</th>
            </tr>
            <tr>
                <td>$role</td>
                <td><span class="type">string</span></td>
                <td>The name of this role</td>
            </tr>
            <tr>
                <td>$inherits</td>
                <td><span class="type">string</span></td>
                <td>Name of the role to inherit from</td>
            </tr>
        </table>
        
        <h4>Example usage</h4>
        <div class="code">
            <?php
            highlight_string('<?php
// $acl is an instance of the Acl Class
$acl->addRole(\'guest\');
$acl->addRole(\'member\', \'guest\');');
            ?>
        </div>
    </div>

    <br />
    <hr />
    <br />
    
    <!-- Acl::allow() -->
    <div id="Acl_allow">
        <h3>+ allow(<span>string</span> $role, <span>string</span> $controller, <span>string/array</span> $actions)<span class="return">:void</span></h3>
        <p>Allow (assign) a resource to a role.</p>

        <table cellspacing="0">
            <tr>
                <th width="100">Parameter</th>
                <th width="60">Type</th>
                <th>Description</th>
            </tr>
            <tr>
                <td>$role</td>
                <td><span class="type">string</span></td>
                <td>The name of the role</td>
            </tr>
            <tr>
                <td>$controller</td>
                <td><span class="type">string</span></td>
                <td>The name of the controller</td>
            </tr>
            <tr>
                <td>$actions</td>
                <td><span class="type">string/array</span></td>
                <td>The action or actions of this controller</td>
            </tr>
        </table>
        
        <h4>Example usage</h4>
        <div class="code">
            <?php
            highlight_string('<?php
// $acl is an instance of the Acl Class

$user_id = 12; // In a real application you will get this from a session or cookie

// The role guest is allowed to access the index action of ALL contollers
$acl->allow(\'guest\', null, \'index\');

// The role member is allowed to access the view action and only the edit action where
// the first parameter is $user_id of the Users controller
$acl->allow(\'member\', \'users\', array(\'view\', \'edit/\' . $user_id));

// The role staff is allowed to access every action of the Users controller
$acl->allow(\'staff\', \'users\', null);

');            
            ?>
        </div>
    </div>
    
    <br />
    <hr />
    <br />
    
    <!-- Acl::checkAcl() -->
    <div id="Acl_checkAcl">
        <h3>+ checkAcl(<span>function</span> $function)<span class="return">:void</span></h3>
        <p>Runs the Acl and checks it's resources! You can pass it an anonymous function as a callback.
        This callback returns you the role name, a request object and a session object.</p>
        
        <p>If you don't pass an anonymous function, it will use the redirect url and redirect
        you to that controller action.</p>

        <table cellspacing="0">
            <tr>
                <th width="100">Parameter</th>
                <th width="60">Type</th>
                <th>Description</th>
            </tr>
            <tr>
                <td>$function</td>
                <td><span class="type">function</span></td>
                <td>Anonymous callback function</td>
            </tr>
        </table>
        
        <h4>Example usage</h4>
        <div class="code">
            <?php
            highlight_string('<?php
// $acl is an instance of the Acl Class
$acl->checkAcl(function($role, $request, $session) {
    echo \'Role: \' . $role;
    
    // You can also use $this
    $this->load->view(\'error\');
});
');            
            ?>
        </div>
    </div>
    
    <br />
    <hr />
    <br />
    
    <!-- Acl::deny() -->
    <div id="Acl_deny">
        <h3>+ deny(<span>string</span> $role, <span>string</span> $controller, <span>string/array</span> $actions)<span class="return">:void</span></h3>
        <p>Deny a resource for a specific role.</p>

        <table cellspacing="0">
            <tr>
                <th width="100">Parameter</th>
                <th width="60">Type</th>
                <th>Description</th>
            </tr>
            <tr>
                <td>$role</td>
                <td><span class="type">string</span></td>
                <td>The name of the role</td>
            </tr>
            <tr>
                <td>$controller</td>
                <td><span class="type">string</span></td>
                <td>The name of the controller</td>
            </tr>
            <tr>
                <td>$actions</td>
                <td><span class="type">string/array</span></td>
                <td>The action or actions of this controller</td>
            </tr>
        </table>
        
        <h4>Example usage</h4>
        <div class="code">
            <?php
            highlight_string('<?php
// $acl is an instance of the Acl Class
...
');            
            ?>
        </div>
    </div>
</div>


<div style="height: 600px;"></div>